﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ehai.Web.Framework.Rules
{

#if DEBUG

    /// <summary>
    /// 获取规则帮助信息的类
    /// </summary>
    public static class HelpInfo
    {

        #region 获取规则帮助信息

        /// <summary>
        /// 获得规则帮助摘要
        /// </summary>
        /// <returns>返回帮助摘要</returns>
        public static string GetAllMsgInfo()
        {
            StringBuilder re = new StringBuilder();
            if (RuleHandleFactory.GetAllRulesName().Length == 0)
                return re.ToString();

            string[] t = RuleHandleFactory.GetAllRulesName();
            re.Append("{");
            for (int i = 0; i < t.Length; i++)
            {
                re.Append(t[i]);
                re.Append(":\"");
                re.Append(UtilTools.TwiceEscapeString(RuleHandleFactory.Create(t[i]).GetHelpInfo()));
                re.Append("\"" + (i == t.Length - 1 ? String.Empty : ","));
            }
            re.Append("}");

            return re.ToString();
        }

        /// <summary>
        /// 获得规则帮助的详细信息字符串
        /// </summary>
        /// <param name="type">规则类型</param>
        /// <returns>返回帮助的详细信息</returns>
        public static string GetHelpDetail(string type)
        {
            IMsgRuleHandle imr = RuleHandleFactory.Create(type);

            return imr != null ? imr.GetHelpDetail() : String.Empty;
        }

        /// <summary>
        /// 获得规则参数的信息
        /// </summary>
        /// <param name="type">规则类型</param>
        /// <returns>返回参数的信息</returns>
        public static string[] GetParametersInfo(string type)
        {
            IMsgRuleHandle imr = RuleHandleFactory.Create(type);

            return imr != null ? imr.GetParametersInfo() : null;
        }

        #endregion

    }

#endif
}
